package c.e.b.h.e.i;

import android.os.Bundle;
import c.e.b.h.e.b;
import c.e.b.h.e.j.a;
import c.e.b.h.e.k.d0;
import c.e.b.h.e.k.f0;
import c.e.b.h.e.k.m;
import c.e.b.h.e.k.t;
import com.huawei.hms.jos.games.ranking.RankingConst;
import java.util.Objects;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: BreadcrumbAnalyticsEventReceiver */
public class d implements b, a {
    public d0 a;

    public static String c(String str, Bundle bundle) throws JSONException {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        for (String str2 : bundle.keySet()) {
            jSONObject2.put(str2, bundle.get(str2));
        }
        jSONObject.put(RankingConst.RANKING_JGW_NAME, str);
        jSONObject.put("parameters", jSONObject2);
        return jSONObject.toString();
    }

    public void a(d0 d0Var) {
        this.a = d0Var;
        b.a.b("Registered Firebase Analytics event receiver for breadcrumbs");
    }

    public void b(String str, Bundle bundle) {
        d0 d0Var = this.a;
        if (d0Var != null) {
            try {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("$A$:");
                stringBuilder.append(c(str, bundle));
                str = stringBuilder.toString();
                f0 f0Var = d0Var.a;
                Objects.requireNonNull(f0Var);
                long currentTimeMillis = System.currentTimeMillis() - f0Var.d;
                t tVar = f0Var.g;
                tVar.e.b(new m(tVar, currentTimeMillis, str));
            } catch (JSONException unused) {
                b.a.f("Unable to serialize Firebase Analytics event to breadcrumb.");
            }
        }
    }
}
